﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SugarWebApi
{

	public class SugarEntry
	{

		protected internal SugarEntry(
			SugarIndexResolver resolver,
			object[] values)
		{
			this._resolver = resolver;
			this._values = values;
		}

		#region Fields

		private SugarIndexResolver _resolver;
		private object[] _values;

		#endregion

		#region Properties

		public string[] Fields
		{
			get { return this._resolver.Fields; }
		}

		#endregion

		public object this[int ordinal]
		{
			get { return this._values[ordinal]; }	
			set { this._values[ordinal] = value; }	
		}

		public object this[string fieldname]
		{
			get { return this._values[this._resolver.IndexOf(fieldname)]; }
			set { this._values[this._resolver.IndexOf(fieldname)] = value; }
		}

		public object this[SugarField field]
		{
			get { return this._values[this._resolver.IndexOf(field)]; }
			set { this._values[this._resolver.IndexOf(field)] = value; }
		}

	}
}
